﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IGGCore;

namespace IGGWindowApp.Panels
{
    public partial class PanelTeam : UserControl
    {
        // EVENTS
        public event EventHandler NextPanelClicked;

        public PanelTeam()
        {
            InitializeComponent();
        }

        public void SetData(Team team)
        {
            lblTeamTitle.Text = team.City + " " + team.Name;
            lbl1bStarter.Text = team.DepthChart.FirstBases[0].FullName;
            lbl1bBackup.Text = team.DepthChart.FirstBases[1].FullName;
            lbl2bStarter.Text = team.DepthChart.SecondBases[0].FullName;
            lbl2bBackup.Text = team.DepthChart.SecondBases[1].FullName;
            lbl3bStarter.Text = team.DepthChart.ThirdBases[0].FullName;
            if (team.DepthChart.ThirdBases.Length > 1)
            {
                lbl3bBackup.Text = team.DepthChart.ThirdBases[1].FullName;
            }
            lblSSStarter.Text = team.DepthChart.Shortstops[0].FullName;
            lblSSBackup.Text = team.DepthChart.Shortstops[1].FullName;

            lblLFStarter.Text = team.DepthChart.LeftFields[0].FullName;
            if (team.DepthChart.LeftFields.Length > 1)
            {
                lblLFBackup.Text = team.DepthChart.LeftFields[1].FullName;
            }

            lblCFStarter.Text = team.DepthChart.CenterFields[0].FullName;
            if (team.DepthChart.CenterFields.Length > 1)
            {
                lblCFBackup.Text = team.DepthChart.CenterFields[1].FullName;
            }
            
            lblRFStarter.Text = team.DepthChart.RightFields[0].FullName;
            if (team.DepthChart.RightFields.Length > 1)
            {
                lblRFBackup.Text = team.DepthChart.RightFields[1].FullName;
                if (team.DepthChart.RightFields.Length > 2)
                {
                    lblRFBackup2.Text = team.DepthChart.RightFields[2].FullName;
                }
            }

            lblCStarter.Text = team.DepthChart.Catchers[0].FullName;
            lblCBackup.Text = team.DepthChart.Catchers[1].FullName;

            if (team.DepthChart.DesignatedHitters != null)
            {
                lblDH.Visible = true;
                lblDHStarter.Visible = true;
                lblDHStarter.Text = team.DepthChart.DesignatedHitters[0].FullName;
                if (team.DepthChart.DesignatedHitters.Length > 1)
                {
                    lblDHBackup.Visible = true;
                    lblDHBackup.Text = team.DepthChart.DesignatedHitters[1].FullName;
                }
            }

            lblSP1.Text = team.DepthChart.Pitchers[0].FullName;
            lblSP2.Text = team.DepthChart.Pitchers[1].FullName;
            lblSP3.Text = team.DepthChart.Pitchers[2].FullName;
            lblSP4.Text = team.DepthChart.Pitchers[3].FullName;
            lblSP5.Text = team.DepthChart.Pitchers[4].FullName;

            lblCloser1.Text = team.DepthChart.Closer.FullName;

            lblReliever1.Text = team.DepthChart.Relievers[1].FullName;
            lblReliever2.Text = team.DepthChart.Relievers[2].FullName;
            lblReliever3.Text = team.DepthChart.Relievers[3].FullName;
            lblReliever4.Text = team.DepthChart.Relievers[4].FullName;
            if (team.DepthChart.Relievers.Length > 5)
            {
                lblReliever5.Visible = true;
                lblReliever5.Text = team.DepthChart.Relievers[5].FullName;
            }
            if (team.DepthChart.Relievers.Length > 6)
            {
                lblReliever6.Visible = true;
                lblReliever6.Text = team.DepthChart.Relievers[6].FullName;
            }
            if (team.DepthChart.Relievers.Length > 7)
            {
                lblReliever7.Visible = true;
                lblReliever7.Text = team.DepthChart.Relievers[7].FullName;
            }
            if (team.DepthChart.Relievers.Length > 8)
            {
                lblReliever8.Visible = true;
                lblReliever8.Text = team.DepthChart.Relievers[8].FullName;
            }
        }

        private void pctNext_Click(object sender, EventArgs e)
        {
            NextPanelClicked(this, null);
        }

        private void cboTeams_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
